import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:text_world/global.dart';
import 'package:text_world/main_manager.dart';
import 'package:text_world/pages/card.dart';
import 'package:text_world/pages/yiju_card.dart';

class YijuPage extends StatefulWidget {
  YijuPage({Key key}) : super(key: key);
  @override
  _YijuPageState createState() => _YijuPageState();
}

class _YijuPageState extends State<YijuPage> {
  List recipeDateList = [];
  bool listLoading = false;
  int page = 2;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    MainManager _mainManager = Provider.of<MainManager>(context);
    return Scaffold(
      appBar: AppBar(
        toolbarHeight: 50,
        elevation: 0,
        title: Text(
          "一句",
          style: TextStyle(
            color: Global.fontColor,
            fontSize: 17,
            fontFamily: 'fangzhengkai',
            fontWeight: FontWeight.w600,
          ),
        ),
        leading: IconButton(
          icon: Icon(
            _mainManager.isLike(_mainManager.hitokoto)
                ? Icons.favorite
                : Icons.favorite_border,
            color: _mainManager.isLike(_mainManager.hitokoto)
                ? Global.likeColor
                : Global.primaryColor,
          ),
          tooltip: '收藏',
          onPressed: () {
            _mainManager.like(_mainManager.hitokoto);
          },
        ),
        actions: <Widget>[
          IconButton(
            icon: Icon(Icons.refresh),
            tooltip: '刷新',
            onPressed: () {
              _mainManager.getNewHitokoto();
            },
          )
        ],
      ),
      body: Container(
        width: MediaQuery.of(context).size.width,
        height: MediaQuery.of(context).size.height,
        color: Global.backgroundColor,
        child: Center(
          child: YijuCard(hitokoto: _mainManager.hitokoto),
        ),
      ),
    );
  }
}
